#!/bin/bash

vip=192.168.50.67
key=1
host_name=DB197
echo '--------------------------------------------------------------------------------' >> /u01/app/oracle/product/12.2.0/db_1/shell/log/vip_switch.log
current_ip=`ssh -p 10001 root@${host_name} /sbin/ifconfig bond0:$key | grep "inet addr" | awk '{ print $2 }' |awk -F: '{print $2}'`
if [ "${current_ip}" = "${vip}" ]; then
	echo "current_ip is [${current_ip}] = [${vip}]"
    	echo $(date "+%Y-%m-%d %H:%M:%S") "------------------- Enable ${host_name} S VIP NONE " >> /u01/app/oracle/product/12.2.0/db_1/shell/log/vip_switch.log
	exit 0;
else
    echo "current_ip is not [${current_ip}] !=[${vip}]"
	echo $(date "+%Y-%m-%d %H:%M:%S") "------------------- Enable ${host_name} S VIP Start." >> /u01/app/oracle/product/12.2.0/db_1/shell/log/vip_switch.log
	`ssh -p 10001 root@${host_name} /sbin/ifconfig bond0:1 ${vip}/26`;
	`ssh -p 10001 root@${host_name} /sbin/arping -I bond0  ${vip} -w 2`;
	echo $(date "+%Y-%m-%d %H:%M:%S") "------------------- Enable ${host_name} S VIP END..." >> /u01/app/oracle/product/12.2.0/db_1/shell/log/vip_switch.log
	exit 0;
fi

